//
//  IAPViewController.swift
//  TestApp
//
//  Created by Toj on 4/1/22.
//

import UIKit

class IAPViewController: UIViewController {
    
    override func viewDidLoad() {
        super.viewDidLoad()
        view.backgroundColor = .white
        
        setupUI()
    }
    
    private func setupUI() {
        view.addSubview(payButton)
        payButton.frame = CGRect(x: 100, y: 100, width: 100, height: 100)
    }
    
    @objc private func didTapPay() {
        
        // 4. 请求苹果后台商品
        // 开发者后台配置的内购产品ID
        let productID = "com.521it.source_iOS" + "01"
//        IAPManager.manager.requestProduct(productID) { state, data in
//            
//        }
    }
    
    private lazy var payButton: UIButton = {
        let view = UIButton()
        view.setTitle("支付", for: .normal)
        view.backgroundColor = .red
        view.addTarget(self, action: #selector(didTapPay), for: .touchUpInside)
        return view
    }()
}
